<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    
        .a{
            /*有父元素且父元素有定位，相对于父元素进行移位*/
            width: 500px;
            height: 500px;
            background-color: blue;
            margin: 0 auto;
            position: relative;
        }
        .b{
            width: 200px;
            height: 200px;
            background-color:green;
            position: absolute;
            top: 50px;
            left: 50px;
        }
        .we{
            /*当没有父元素或者父元素没有定位，参照物是浏览器的窗口的第一屏*/
            width: 200px;
            height: 200px;
            background-color: greenyellow;
            position: absolute;
            left: 100px;
        }
    </style>
</head>
<body>
    <!-- 脱离文档流 -->
    <div class="a">
        <div class="b"></div>
    </div>
    <div class="we">

    </div>
</body>
</html>